﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RMS.DataAccess.Entities;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RMS.Web.Shell.Presenter;
using RMS.Web.Shell.View;
using RMS.Utils.MVP;
using RMS.Utils.Navigator;
namespace RMS.DAL
{
    public class PatientRepository:IPatientRepository
    {
        public IQueryable<Patient> GetPateints()
        {
            var dataContext = new Northwind();
            var Pateints =from p in dataContext.Patients
                         select p;
            return Pateints;
        }
        public IQueryable<PatientsView> GetPatientProjected(int? PatientID)
        {
            var projectedPatient = from p in GetPatients()
                                    select new PatientsView
                                    {
                                        PatientID = p.PatientID,
                                        FirstName = p.FirstName,
                                        FamilyName = p.FamilyName,
                                        Gender = p.Gender,
                                        Birthday = p.Birthday,
                                        
                                    };
             
            if (PatientID.HasValue)
            {
                projectedPatient = projectedPatient.Where(a => a.PatientID == PatientID);
            }




            return projectedPatient;
        }



        public IQueryable<PatientsView> projectedPatient { get; set; }

        public IQueryable<RadiologyRequest> getRadiologyRequest()
        {
            var dataContext = new Northwind();
            var RadiologyRequest = from p in dataContext.RadiologyRequest
                            select new RadiologyRequestView
                            {
                                RequestId =p.RequestId,
                                RequestDate = p.RequestDate,
                            };
            return RadiologyRequest;
        }
    }

}